import java.util.*;

public class Problem {
    public static void main1() {
        Scanner scanner=new Scanner(System.in);
        int t=scanner.nextInt();
        while(t-->0){
            int n=scanner.nextInt();
            int m=scanner.nextInt();
            int[] num=new int[m];
            Set<Integer> set=new TreeSet<>();
            String s= scanner.next();
            for (int i = 0; i < m; i++) {
                num[i]=scanner.nextInt();
                set.add(num[i]);
            }
            String c=scanner.next();
            char[] cStr=c.toCharArray();
            Arrays.sort(cStr);
            char[] ans=s.toCharArray();
            int j=0;
            for(Integer values:set){
                ans[values-1]=cStr[j++];
            }
            System.out.println(new String(ans));
        }
    }

    public static void main2(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int t=scanner.nextInt();
        while (t-->0){
            int x=scanner.nextInt(),y=scanner.nextInt(),z=scanner.nextInt();
            long k=scanner.nextLong(),max=0;
            for (long i = 1; i <= x; i++) {
                for (long j = 1; j <= y; j++) {
                    if(k%(i*j)==0&&k/(i*j)<=z){
                        max=Math.max(max,(x-i+1)*(y-j+1)*(z-k/(i*j)+1));
                    }
                }
            }
            System.out.println(max);
        }
    }

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String s=scanner.next();
        int[] arr=new int[s.length()];
        int b=0;
        for (int i = 0; i < s.length(); i++) {
            arr[i]=b;
            if(s.charAt(i)=='('){
                b++;
            }
            else {
                b--;
            }
        }
        Integer[] f=new Integer[s.length()];
        for (int i = 0; i < s.length(); i++) {
            f[i]=i;
        }
        Arrays.sort(f,(i,j)->
        {
            if(arr[i]!=arr[j]){
                return Integer.compare(arr[i],arr[j]);
            }
            return Integer.compare(j,i);
        });
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            result.append(s.charAt(f[i]));
        }
        System.out.println(result.toString());
    }
}